import { ApiProperty } from '@midwayjs/swagger';
import { Rule, RuleType } from '@midwayjs/validate';
import { Column, Entity, PrimaryColumn } from 'typeorm';
@Entity({
  synchronize: false,
  name: 'Animation',
})
export class Animation {
  @ApiProperty({ example: '' })
  @Rule(RuleType.string().allow('').allow(null).required())
  @PrimaryColumn()
  aniCode: string = '';
  @ApiProperty({ example: '动漫1' })
  @Rule(RuleType.string().allow('').allow(null).required())
  @Column({ nullable: true })
  title: string = 'Animation';
  @ApiProperty({ example: 10.05 })
  @Rule(RuleType.number().required())
  @Column({
    type: 'decimal',
    precision: 18,
    scale: 2,
    transformer: {
      to(data: number): number {
        return data;
      },
      from(data: string): number {
        return parseFloat(data);
      },
    },
  })
  price: number = 0.0;
  @ApiProperty({ example: 1 })
  @Rule(RuleType.number().required())
  @Column({ default: 1 })
  quantity: number = 1;
  @ApiProperty({ example: '' })
  @Rule(RuleType.string().allow('').allow(null).optional())
  @Column({ nullable: true })
  cover: string = '/xxx/some.png';
}
export class AnimationQC {
  @ApiProperty({ example: '' })
  @Rule(RuleType.string().allow('').allow(null).required())
  titleLike: string = '';
  
  @ApiProperty({ example: 1 })
  @Rule(RuleType.number().min(1).required())
  pageNum: number;
  @ApiProperty({ example: 3 })
  @Rule(RuleType.number().min(1).required())
  pageSize: number;
}
